<template>
<view class="page-body">
	<view class="schedule">
		<view class="type">{{status_description}}</view>
		<!-- <view class="time">2019-08-19 13:13:12</view> -->
	</view>
	<view class="hang total">
		<text>退款总金额</text>
		<text>￥{{refurnOrder.apply_amount}}</text>
	</view>
	<!-- <view class="hang" @click="history">
		<text >协商历史</text>
		<view class="icon xiangyou"></view>
	</view> -->
	<view class="row block" >
		<view class="type">退款信息</view>
		<view class="order-info" >
			<view class="left">
				<image :src="orderData.goods_thumb"></image>
			</view>
			<view class="right">
				<view class="name">
					{{orderData.goods_name}}
				</view>
				<view class="spec">{{orderData.attr_value_str}}</view>
				<view class="price-number">
					￥<view class="price">{{orderData.goods_amount}}</view>
					x<view class="number">{{orderData.goods_num}}</view>
				</view>
			</view>
		</view>
		<view class="refunds-msg" style="padding-top: 20upx;">
			<view>退款类型：{{refurnOrder.after_sales_type}}</view>
			<view>退款原因：{{refurnOrder.apply_reason}}</view>
			<view>退款金额：￥{{refurnOrder.apply_amount}}</view>
			<view>申请时间：{{refurnOrder.apply_time}}</view>
			<view>退款编号：<text selectable>{{refurnOrder.return_no}}</text></view>
		</view>
	</view>

	<view class="row block" v-if="refurnOrder.status!=0">
		<view class="type">退货信息</view>
		<view class="refunds-msg">
			<view>收货人：{{business.contact_name}}</view>
			<view>收货电话：{{business.contact_tel}}</view>
			<view>收货地址：{{business.contact_address}}</view>
		</view>
	</view>
	<view class="row block" v-if="refurnOrder.status==2">
		<view class="type">物流信息</view>
		<view class="refunds-msg">
			<view>物流公司：{{refurnOrder.return_express}}</view>
			<view>物流单号：{{refurnOrder.return_express_no}}</view>
		</view>
	</view>
	<view></view>
	<view class="btn-fill" v-if="refurnOrder.status==1"  @click="fillLogistics">填写物流信息 <text class="icon xiangyou"></text></view>
	<view class="btn-fill btn-cancel" v-if="refurnOrder.status==0" @click="cancelRefunds">取消退款</view>

</view>
</template>

<script>
	var that;
	import {formatDateTime} from '@/utils/utils.js';
	export default{
		data(){
			return {
				row:"",
				rid:"",
				refurnOrder:"",
				orderData:"",
				status_description:"退货处理中",
				business:""
			}
		},
		onLoad(options){
			that = this;
			// let row=JSON.parse(decodeURIComponent(options.goodsmsg));
			// let ordermsg= this.row = row;
			this.rid = options.rid;
		},
		onShow() {
			this.getRefundDec()
		},
		methods:{
			getRefundDec(){
				that.$https.POST({
					url:'/order/returnRequestDetails',
					data:{
						rid:that.rid
					},
					success(res){
						res.data.returnOrder.apply_time = formatDateTime(res.data.returnOrder.apply_time*1000,1);
						that.refurnOrder = res.data.returnOrder;
						that.orderData = res.data.order;
						that.business = res.data.business
						if(res.data.order.order_status==5){
							that.status_description = "商品退货处理中"
						}
						if(res.data.order.order_status==6){
							that.status_description = "退货完成"
						}
					}
				})
			},
			fillLogistics(){
				let rid = this.rid;
				uni.navigateTo({
					url:"./fill_logistics?rid="+rid
				})
			},
			/* 取消退货 */
			cancelRefunds(){
				let refundsid = this.refundsid
				uni.showModal({
					title:"取消退货",
					content:"是否确定取消退货",
					success:(res)=>{
						if(res.confirm){
							that.$https.POST({
								url:'/order/removeReturnRequest',
								data:{
									rid:that.rid
								},
								success(res){
									uni.navigateBack()
								}
							})
						}
					}
				})
			},
			history(){
				uni.navigateTo({
					url:"./history"
				})
			},
		},
		onUnload(){
			that=null;
		}
	}
	
</script>

<style lang="scss">
	page{background: #f5f5f5; padding-bottom: 105rpx;}
	.total{
		border-bottom: 1px solid #f8f8f8;
		text:nth-of-type(2){color: #fb3232;font-size: 30upx;}
	}
	.hang{line-height: 80upx;display: flex;justify-content: space-between;box-sizing: border-box;padding: 0 20upx;background: #fff;font-size:30upx;
		// .xiangyou{font-size: 28upx;}
	}
	.schedule{
		height:160upx;background: #e65339; color: #fff; display: flex; justify-content: center; box-sizing: border-box; padding: 0 20upx; flex-direction: column;
		.type{font-size: 34upx;line-height: 60upx;}
		.time{font-size: 26upx;}
	}
	.refunds-msg{
		padding: 0 20upx 20upx;box-sizing: border-box;background: #fff;color:#666;
		view{line-height: 46upx;}
	}
	.pd20{padding:0 20upx;}
	.block{
		border-radius: 10upx;
		margin-bottom: 20upx;
	}
	.line-sb{display: flex;justify-content: space-between;}
	.address{
		display: flex;align-items: center; padding:20upx;
		.address-info{
			margin-left: 20upx; line-height: 40upx;font-size: 28upx;
			.contact{color: #888;margin-left: 20upx;}
		}
	}
	.goods-sum{
		font-size: 26upx;color: #808080; line-height: 50upx;
		.underline{font-size:28upx ;color: #333;}
	}
	.order-msg{
		.h3{font-size: 30upx;color: #333333;line-height: 70upx;}
		.line-defalut{
			display: flex;font-size: 26upx;color: #666;line-height: 60upx;
			text{width:190upx;}
		}
	}
	/* 商品样式 */
	.row{
		.type{
			font-size: 30upx;
			color: #444;
			height: 80upx;
			display: flex;
			align-items: center;
			padding:0 20upx ;
			background: #fff;
		}
		.order-info{
			padding: 20upx; box-sizing: border-box;
			width: 100%;
			display: flex;
			.left{
				flex-shrink: 0;
				width: 25vw;
				height: 25vw;
				image{
					width: 25vw;
					height: 25vw;
					border-radius: 10upx;
				}
			}
			.right{
				width: 100%;
				margin-left: 10upx;
				position: relative;
				.name{
					width: 100%;
					font-size: 28upx;
					display: -webkit-box;
					-webkit-box-orient: vertical;
					-webkit-line-clamp: 2;
					overflow: hidden;
				}
				.spec{
					color: #a7a7a7;
					font-size: 22upx;
	
				}
				.price-number{
					position: absolute;
					bottom: 0;
					width: 100%;
					display: flex;
					justify-content: flex-end;
					font-size: 22upx;
					color: #333;
					display: flex;
					align-items: center;
					height:40upx;
					line-height:40upx;
					.price{
						font-size: 24upx;
						margin-right: 5upx;
					}
					
				}
			}
		}
	}
	.btn-bottom{background: #fff;position: fixed;bottom: 0;left: 0;width: 100%;padding-right:20upx ;box-sizing: border-box;}
	.btns{
		height: 80upx;
		display: flex;
		align-items: center;
		justify-content: flex-end;
		view{
			min-width: 120upx;
			height: 50upx;
			padding: 0 20upx;
			border-radius: 50upx;
			display: flex;
			justify-content: center;
			align-items: center;
			font-size: 28upx;
			margin-left: 20upx;
		}
		.default{
			border: solid 1upx #ccc;
			color: #666;
		}
		.pay{
			border: solid 1upx #ec652f;
			color: #ec652f;
		}
	}
	.btn-fill{width: 100%;text-align: center;line-height: 88upx;height: 88upx;color: $maincolor;font-size: 30upx;background: #fff;margin: 16upx 0 0;border-bottom: 1px solid #efefef;
		.xiangyou{font-size: 28upx;color: $maincolor;}
	}
	.btn-cancel{color: #333;}
</style>
